<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
	<% String path=request.getContextPath(); String basePath=request.getScheme() + "://" + request.getServerName() + ":"
		+ request.getServerPort() + path + "/" ; %>

		<!DOCTYPE html>
		<html>

		<head>
			<base href="<%=basePath%>">

			<title>附件表</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

		</head>

		<body>
			<%@ include file="/WEB-INF/jsp/common/header.jsp" %>
				<%@ include file="/WEB-INF/jsp/common/loadDiv.jsp" %>

					<script type="text/javascript">
						$(function () {
							$('#startTime').datebox('setValue', getBeforeCurrentDate30Days());
							$('#endTime').datebox('setValue', getNowFormatDate());
							bindgrid();
						});
					</script>
					<script>
						function del(node) {
							$.ajax({
								type: "delete",
								url: 'schedule/job/log/delete?id=id',
								//                dataType: "xml",				
								success: function (data) {
									$.messager.alert('消息', data);
									$('#add').window('close');
									bindgrid();
								},
								error: function (XMLHttpRequest, textStatus, errorThrown) {
									$.messager.alert('消息', errorThrown);
								}
							});
						}

						function save() {
							$('#fm').form('submit', {
								url: 'schedule/job/log/save',
								iframe: false,
								onSubmit: function () {
									return $(this).form('validate');
								},
								success: function (result) {
									var result = eval('(' + result + ')');
									if (result.errorMsg) {
										$.messager.show({
											title: 'Error',
											msg: result.errorMsg
										});
									} else {
										$('#dlg').dialog('close'); // close the dialog
										$('#dg').datagrid('reload'); // reload the user data
									}
								}
							});
						}

						function editrow() {
							//编辑用户
							var row = $('#dg').datagrid('getSelected');
							if (row) {
								$('#add').window('open');
								$('#fm').form('load', row);

							} else {
								$.messager.alert('消息', '请选中一个用户');
							}
						}
					</script>
					<script>
						function selectList() {
							var startTime = $('#startTime').datebox('getValue')
							var endTime = $('#endTime').datebox('getValue')
							var dg = $('#dg');
							dg.datagrid('enableFilter');
							dg.datagrid('load', {
								startTime: startTime ? startTime : '',
								endTime: endTime ? endTime : ''
							});
						}
						function bindgrid() {
							var startTime = $('#startTime').datebox('getValue')
							var endTime = $('#endTime').datebox('getValue')
							$('#dg').datagrid(
								{
									title: '日志列表',
									url: "schedule/job/log/selectList",
									iconCls: 'icon-application',
									queryParams: {
										startTime: startTime,
										endTime: endTime
									},
									width: getWidth(0.98),
									height: 415,
									filterDelay: 0,
									nowrap: true,
									rownumbers: true,
									animate: false,
									collapsible: false,
									clientPaging: false,
									remoteFilter: true,
									singleSelect: true,
									pagination: true,
									remoteSort: true,
									columns: [[{
										field: 'id',
										title: 'Id',
										sortable: true,
										hidden: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'jobId',
										title: '定时任务Id',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'beanName',
										title: 'Bean名称',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'methodName',
										title: 'Method名称',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'params',
										title: '参数',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'runStatus',
										title: '状态0：成功    1：失败  2：执行中',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'errorLog',
										title: '错误日志',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'times',
										title: '执行时长(单位毫秒)',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'beginTime',
										title: '开始执行时间',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}, {
										field: 'endTime',
										title: '结束执行时间',
										sortable: true,
										formatter: function (val, rec) {
											return val ? unescape(val) : '';
										}
									}]],
									toolbar: [
										{
											text: '增加',
											iconCls: 'icon-add',
											handler: function () {
												$('#fm').form('clear');
												$('#add').window('open');
											}
										},
										'-',
										{
											text: '编辑',
											iconCls: 'icon-edit',
											handler: function () {
												var row = $('#dg').datagrid(
													'getSelected');
												if (row) {
													$('#add').dialog('open').dialog(
														'center').dialog(
															'setTitle', '');
													$('#fm').form('load', row);

												}
											}
										},
										'-',
										{
											text: '删除',
											iconCls: 'icon-cancel',
											handler: function () {
												var row = $('#dg').datagrid(
													'getSelected');
												if (row) {
													$.messager.confirm('提示',
														'确定要删除吗?', function (r) {
															if (r) {
																del(row);
															}
														});
												}
											}
										}],
									onLoadSuccess: function () {
									},
									onDblClickRow: function () {
										editrow();
									}
								});
							$('#dg').datagrid('enableFilter');
						}
					</script>
					<style scoped="scoped">
						.textbox {
							height: 20px;
							margin: 0;
							padding: 0 2px;
							box-sizing: content-box;
						}

						/*.table tr {
        height: 15px;
    }*/
					</style>
					<div style="margin: 5px 0px">
						<%-- 搜索框 --%>
							<label style="font-size: 12px;">创建时间：</label> <input class="easyui-datebox" name="startTime"
								id="startTime"
								data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
								value="" style="width: 150px"> <label style="font-size: 10px;">~</label> <input
								class="easyui-datebox" name="endTime" id="endTime"
								data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
								style="width: 150px" /> <a id="search" style="margin-left: 30px"
								href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'"
								onclick="selectList()">查询</a>
					</div>
					<table id="dg"></table>


					<div id="add" class="easyui-window" closed="true" modal="true" title="用户信息"
						style="width: 500px; height: 450px; padding: 10px 20px">
						<form id="fm" class="ssec-form">
							<table class="table">
								<tr>
									<td>
										<div class="ssec-label">Id：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="id" name="id" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">定时任务Id：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="jobId" name="jobId" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">Bean名称：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="beanName" name="beanName" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">Method名称：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="methodName" name="methodName" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">参数：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="params" name="params" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">状态0：成功 1：失败 2：执行中：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="runStatus" name="runStatus" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">错误日志：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="errorLog" name="errorLog" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">执行时长(单位毫秒)：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="times" name="times" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">开始执行时间：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="beginTime" name="beginTime" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">结束执行时间：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="endTime" name="endTime" class="easyui-validatebox textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
							</table>
							<div style="padding: 5px; text-align: right;">
								<!-- <a class="easyui-linkbutton" onclick="save();" iconcls="icon-save">保存</a> -->
							</div>
						</form>
					</div>
		</body>

		</html>